package cn.schoolwow.workflow.module.definition.query.service;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.workflow.entity.WorkFlowDefinition;

public class HasDeployWorkFlowServiceFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);
        String name = flowContext.checkData("name", String.class);

        dao.addRecordString("判断工作流实例是否已经部署");
        long count = dao.query(WorkFlowDefinition.class)
                .addQuery("name", name)
                .execute()
                .count();
        if(count>0){
            flowContext.putTemporaryData("exist", true);
        }else{
            flowContext.putTemporaryData("exist", false);
        }
    }

    @Override
    public String name() {
        return "工作流定义是否已经部署过服务流程";
    }
}
